<style lang="less">
  .quesDiv1{
    .ivu-card-body{
      padding: 0;
    }
    .con{
      .ivu-card-body{
        padding: 0 16px 16px 16px;
      }
    }
  }
  /* 手机竖屏 */
  @media screen and (min-width: 0px) and (max-width: 820px) {
    .quesDiv1{
      .ivu-card-head{
        padding: 6px 8px !important;
        background: #fff;
      }
      .ivu-card-extra {
        top: 4px !important;
        right: 0 !important;
      }
    }
  }
</style>
<template>
  <Card class="quesDiv1">
    <p slot="title" v-html="phoneStyle?'问题':'问题&待处理事项'"></p>
    <div class="conButtons" slot="extra">
      <div class="buts chooseButs" @click="toQuestion" v-if="isIndex">添加事件</div>
      <div :class="1 == chooseQS?'buts chooseButs':'buts'" @click="chooseQSB(1)">全部</div>
      <div :class="4 == chooseQS?'buts chooseButs':'buts'" @click="chooseQSB(4)">待处理</div>
      <div :class="0 == chooseQS?'buts chooseButs':'buts'" @click="chooseQSB(0)">进行中</div>
      <div :class="3 == chooseQS?'buts chooseButs':'buts'" @click="chooseQSB(3)">已完结</div>
    </div>
    <div class="contentDivIndex" v-if="quesDivData.length > 0">
      <div class="con" v-for="item in quesDivData" @click="questionClick(item.problem_id,item.unit_id)">
        <Card>
          <div
              :class="{'blueL colorLabel':item.grade_id == 0,'yellowL colorLabel':item.grade_id == 1,'orangeL colorLabel':item.grade_id == 2,'redL colorLabel':item.grade_id == 3,'garyL colorLabel':item.grade_id == 4}">
            {{returnColor(item.grade_id)}}
          </div>
          <div class="times">
            <div class="timesLeft">{{ item.create_time }} {{ item.header_user_name }}</div>
            <div class="timesRight">{{item.status_name}}</div>
          </div>
          <div class="conText">{{ item.title }}</div>
        </Card>
      </div>
    </div>
    <div class="noMore" v-else><Icon type="md-thumbs-up" />所有问题都已经处理完成，真有效率！</div>
  </Card>
</template>

<script>
  export default {
    props: ['quesDivData', 'isIndex'],
    name: "quesDiv",
    data() {
      return {
        chooseQS: 0,
        phoneStyle: false,
      }
    },
    created() {
      let self = this
      let dw = document.body.clientWidth
      if (dw < 820) {
        self.phoneStyle = true
      } else {
        self.phoneStyle = false
      }
    },
    methods: {
      toQuestion() {
        this.$router.push('/item/question/questionNew?id=' + this.$route.query.id)
      },
      chooseQSB(index) {
        let self = this
        self.chooseQS = index
        this.$emit('needChange', index)
      },
      questionClick(qid, unit_id) {
        this.$router.push({
          path: '/item/question/questionDetail',
          query: {id: unit_id, problemId: qid, node: 0}
        })
      },
      returnColor(color) {
        switch (parseInt(color)) {
          case 0:
            return '蓝色';
          case 1:
            return '黄色';
          case 2:
            return '橙色';
          case 3:
            return '红色';
          case 4:
            return '其他';
        }
      },
    }
  }
</script>

<style lang="less" scoped>
  .quesDiv1 {
    background: #f9f9f9;
    .ivu-card-head {
      background: #fff;
    }
    .ivu-card-extra {
      top: 11px;
      .conButtons {
        display: flex;
        flex-direction: row;
        .buts {
          padding: 4px 8px;
          background: #f5f5f5;
          font-size: 14px;
          color: #666666;
          margin-right: 10px;
          cursor: pointer;
          border-radius: 3px;
        }
        .chooseButs {
          background: #3f8fe0;
          color: #fff;
        }
      }
    }
    .ivu-card-body {
      background: #fff;
      padding-top: 0 !important;
    }
    .contentDivIndex {
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      max-height: 305px;
      overflow-y: auto;
      padding: 0 16px 16px 16px;
      box-sizing: border-box;
      .con {
        width: 32%;
        margin-right: 10px;
        margin-top: 16px;
        display: flex;
        flex-direction: column;
        position: relative;
        cursor: pointer;
        .ivu-card-body {
          width: 100%;
          height: 100%;
          background: #fff;
          padding-top: 16px;
          .colorLabel {
            display: block;
            width: 40px;
            height: 20px;
            line-height: 20px;
            text-align: center;
            font-size: 8px;
            color: #fff;
            position: absolute;
            top: 0;
            left: 16px;
          }
          .blueL {
            background: #3384dd;
          }
          .yellowL {
            background: #f2ca51;
          }
          .orangeL {
            background: #ffb11b;
          }
          .redL {
            background: #f15c60;
          }
          .garyL {
            background: #cccccc;
          }
          .times {
            display: flex;
            flex-direction: row;
            justify-content: space-between;
            margin-top: 25px;
            margin-bottom: 10px;
            line-height: 13px;
            .timesLeft {
              font-size: 12px;
              color: #666666;
            }
            .timesRight {
              font-size: 13px;
              color: #3f8fe0;
            }
          }
          .conText {
            font-size: 13px;
            color: #222222;
            height: 20px;
            overflow: hidden;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
          }
          .needExplain {
            color: #dc4444;
          }
        }
      }
    }
    .noMore {
      width: 100%;
      height: 150px;
      text-align: center;
      line-height: 150px;
      font-size: 14px;
      color: #999999;
      background: #f9f9f9;
      .ivu-icon{
        font-size: 30px;
        margin-right: 5px;
      }
    }
  }
  /* 手机竖屏 */
  @media screen and (min-width: 0px) and (max-width: 820px) {
    .quesDiv1{
      .ivu-card-extra {
        .conButtons {
          display: flex;
          flex-direction: row;
          .buts {
            padding: 2px 4px;
            background: #f5f5f5;
            font-size: 14px;
            color: #666666;
            margin-right: 5px;
            cursor: pointer;
            border-radius: 3px;
          }
          .chooseButs {
            background: #3f8fe0;
            color: #fff;
          }
        }
      }
      .contentDivIndex{
        background: #f9f9f9;
        padding: 0 8px 8px 8px;
        .con{
          width: 100%;
          margin-right: 0;
          .ivu-card{
            padding: 8px !important;
          }
        }
      }
    }
  }
</style>